<?php

namespace App\Http\Middleware\Admin;

use Closure;
use View;

class Login
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        if (!session()->has('admin')) {
            return redirect('admin/login');
        }
        $sessionData = session()->all();
        View::share(['sessionData' => $sessionData]);
        return $next($request);
    }
}
